<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
</head>
<style>
  body {
    height: 2000px;
  }

  .inner {
    width: 200px;
    height: 200px;
    border: 1px solid black;
    background-color: yellow;
    position: sticky;
    margin-top: 0px;
    top:0px;

  }

  .wrap {
    width: 1200px;
    height: 1200px;
    border: 1px solid red;

  }
</style>

<body>
  <div class="wrap">
    <div class="inner">fdsijo</div>
  </div>
</body>

</html>